/* 
 * File:   Error.cpp
 * Author: wolsiefferb
 * 
 * Created on May 1, 2013, 10:21 AM
 */

#include "Error.h"
#include <string>
using namespace logger;

const Error Error::kInvalidJoystickName(1, std::wstring(L"Specified joystick not found"));
const Error Error::kNoJoystickFound(2, std::wstring(L"No joystick found"));
// Skip error codes to be the same as the Java version (the skipped errors don't exist right now in C++)
const Error Error::kSetJoystickDataFormatFailed(5, std::wstring(L"Unable to set joystick data format"));
const Error Error::kSetJoystickRangeFailed(6, std::wstring(L"Unable to set joystick range"));
const Error Error::kSetJoystickAxisModeFailed(7, std::wstring(L"Unable to set joystick axis mode"));

Error::Error(const int code, const std::wstring&& message) : mMessage(message), mCode(code) {
}

Error::Error(const Error& orig) : mMessage(std::wstring(orig.mMessage)), mCode(orig.mCode) {
}

Error::~Error() {
}

void Error::log(std::wostream& stream) const {
    stream << "Error " << mCode << ": " << mMessage << std::endl;
	exit(mCode);
}

int Error::getLevel() const {
    return 2;
}